package com.acme.bankapp.domain.bank;

import java.util.ArrayList;
import java.util.Date;


public class Bank {
	
	private ArrayList<Client> clients;
	private ClientRegistratrationListner[] listeners;
	private DebugListener listener=new DebugListener();;

	public Bank(){
		clients=new ArrayList<Client>();
		listeners=new ClientRegistratrationListner[2];
		listeners[0]=new PrintClientListener();
		listeners[1]=new EmailNotificationListener();
	}
	
	public ArrayList<Client> getClients() {
		return clients;
	}
	
	public void addClienT(Client client){
		clients.add(client);
		
		for(ClientRegistratrationListner cl: listeners) {
			cl.onClientAdded(client);
		}
	}
	
	class PrintClientListener implements ClientRegistratrationListner{

		@Override
		public void onClientAdded(Client c) {			
			System.out.print(c.getName() + "  ");
			listener.printDate();
		}		
	}
	
	class EmailNotificationListener implements ClientRegistratrationListner{

		@Override
		public void onClientAdded(Client c) {
			System.out.println("Notifiction email for client "+c.getName()+" to be sent");
		}
		
	}
	
	class DebugListener{
		public void printDate(){
			System.out.println(new Date());
		}
	}
}
